package com.springcloud.web;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class TestController {

    @Resource
    private RestTemplate restTemplate;
    @GetMapping("/test")
    public String test01(){
//        RestTemplate restTemplate=new RestTemplate();
        ResponseEntity<String> forEntity = restTemplate.getForEntity("http://eureka-client-provider/test", String.class);
        System.out.println(forEntity.getStatusCode());
        System.out.println(forEntity.getStatusCodeValue());
        System.out.println(forEntity.getHeaders());
        String body = forEntity.getBody();
        System.out.println(body);
        return "这是Eureka消费者"+"-------------"+body;
    }

}
